package com.hongyi.app.factory;

import com.hongyi.app.mapper.PermissionMapper;
import com.hongyi.app.mapper.RoleMapper;
import com.hongyi.app.mapper.RolePermissionMapper;
import com.hongyi.app.mapper.UserMapper;
import com.hongyi.app.service.RoleService;
import com.hongyi.app.service.impl.RoleServiceImpl;
import lombok.extern.slf4j.Slf4j;

/**
 * @author HongYi
 */
@Slf4j
public class RoleServiceFactory {

    public  RoleServiceFactory(){
        /**
         * 测试spring是否new工厂
         */
        log.info("RoleServiceFactory被实例化");
    }

public static RoleService getInit(RoleMapper roleMapper, RolePermissionMapper rolePermissionMapper
, PermissionMapper permissionMapper, UserMapper userMapper){

        //手动IOC
    RoleServiceImpl roleService = new RoleServiceImpl();

    //手动DI
    roleService.setRoleMapper(roleMapper);
    roleService.setRolePermissionMapper(rolePermissionMapper);
    roleService.setPermissionMapper(permissionMapper);
    roleService.setUserMapper(userMapper);

        return roleService;
}

 }
